-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Refactor common utils out of ML plugin to XPack.Core #39976
[ML] Refactor common utils out of ML plugin to XPack.Core #39976
Conversation
Pinging @elastic/ml-core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just 1 comment/opinion
@@ -38,7 +37,7 @@ | |||
public QueryPage(List<T> results, long count, ParseField resultsField) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devils advocate: as we are moving this into a more prominent place, we should discuss the naming of this, I think QueryPage
doesn't fit. It's rather a ResultPage
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, definitely a possibility. I think the name QueryPage
is an artifact of indicating that "This is the results of a Query", but ResultPage
does give a broader indication as there is nothing restricting the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dimitris-athanasiou ^^ what say you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would even say it is just a Page
:-) However, changing this might cause BWC problems, at least on the HLRC and transport level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this change is already breaking for transport client users (so I added the >breaking-java
label). To move a class from one package to another is not too hard to cope with for a developer with an IDE, as the IDE will find the class of the same name in its new place. But to change both the package and the name of a class in a refactoring is quite unfriendly. Plus if the class is renamed server-side then the HLRC equivalent should be renamed to match, and that means we cause work for HLRC users as well as transport client users (as well as extra work for ourselves changing the HLRC docs). So I am also of the opinion that we should stick with the current name even if it isn't perfect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see (a) QueryPage
being used in HLRC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see (a)
QueryPage
being used in HLRC.
Yes, that's true. The HLRC responses just contain Java List
s. So we didn't maintain the interface for response objects between the transport client and the HLRC. I thought we had. Sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, we've already stepped away from it there with the AbstractResultResponse
. I'm glad we did that :-)
@benwtrent I would suggest that this PR has at least one implementation of the transport action. This will also enable testing all that logic. For simplicity, you could start with the get-filters action. It should be straightforward (similar to the implementation of this in the df-analytics branch). |
As others already pointed out, I think this might be a risky change. I therefore bring up the option to introduce the abstractions in core but not to immediately migrate existing ML API's to it. We will use the new abstractions for the new functionality. This gives us time and freedom to stabilize the new abstractions without BWC pain. At a later point we can migrate ML API's after proper testing. |
I don't think it's that risky, although I do think we'll find it's not generic enough in the future. We have YAML tests that exercise all the REST endpoints that correspond to the refactored actions, so they prove that this change has not broken the existing REST endpoints. I also think if we develop new abstractions with a plan to migrate existing endpoints to them after 7.1 but don't actually do that for 7.1 then it's more likely to mean BWC headaches or never migrating the existing endpoints to the new abstractions. There are 3 new abstract classes here, for the request, response and transport action. The request and response abstract classes are the simplest and least likely to cause problems. The abstract transport action is the one that's most likely to cause grief in the future. One thing I can see that's missing is for the I also think that we will find actions where the request and response classes can extend these abstract classes but the transport action cannot, due to having to do something differently. But I don't think that's a problem. I do agree with @dimitris-athanasiou that it would be best to implement one transport action that extends the abstract transport action just to make sure it is usable in at least one case. But after that I'd be happy to merge this PR. |
|
||
public abstract class AbstractGetResourcesRequest extends ActionRequest { | ||
|
||
public static final String ALLOW_NO_RESOURCES = "allow_no_resources"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a bit too abstract to be exposed to end users. Where we've exposed this in the past it's been in more targeted parameters like allow_no_jobs
. So I think each group of classes that extend this class should define their own parameter rather than the abstract class suggesting one.
} | ||
getListRequest.setAllowNoResources(restRequest.paramAsBoolean(ALLOW_NO_RESOURCES, true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it has moved beyond refactoring to adding new functionality. I would say that this PR should just hardcode true
here, as that's what the behaviour was before. (If we were to have a parameter to say finding no filters was unacceptable then maybe we'd want to call it allow_no_filters
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
run elasticsearch-ci/1 |
@jasontedor ping This PR added some commonly useful code to |
When get filters is called without setting the `size` paramter only up to 10 filters are returned. However, 100 filters should be returned. This commit fixes this and adds an integ test to guard it. It seems this was accidentally broken in elastic#39976. Closes elastic#54206
When get filters is called without setting the `size` paramter only up to 10 filters are returned. However, 100 filters should be returned. This commit fixes this and adds an integ test to guard it. It seems this was accidentally broken in elastic#39976. Closes elastic#54206 Backport of elastic#54207
3 new abstract classes to aid in getting resources.
minor refactors required for such, moved QueryPage, ExpandedIdsMatcher, and PageParams into xpack.core.action.util.
Refactored some of the ML responses. More refactoring will have to be done to rewrite the transports to take advantage of the new abstract class, but did not want this PR to become thousands of lines of changes.